import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, sim_items, main, dungeon
from util import *

class Scroll(sim_items.Scroll):
    def __init__(self):
        sim_items.Scroll.__init__(self, "illumination", "?", 
                ('light', 'far', 'more'),
                idDescription="This scroll contains a highly alliterative "\
                    "droning chant. As each syllable is recited the ambient "\
                    "light gradually increases and by the end of the chant "\
                    "darkness itself is banished, albeit temporarily.")

    def read(self, reader):
        self.map = main.mapFrame.getMap()
        self.originalIntensity = main.originalAmbientIntensity[self.map]

        self.map.setAmbientLight((255,255,255), 0.4)
        self.map.update()

        main.schedule.add(sim.Event('expire effect', main.schedule.time + 2*60000,
            (self,), dests=[self]))
        reader.identify(self)

    def listen(self, event):
        sim_items.Scroll.listen(self, event)

        if event.id == 'expire effect' and event.args[0] is self:
            self.map.setAmbientLight((255,255,255), self.originalIntensity)
            self.map.update()


#========================================
thingClass = Scroll


